local jingying = {}

-- 点击经营按钮
jingying.tapJingying = function()
  LuaAuxLib.TracePrint("寻找经营按钮")
  local isKeep = LuaAuxLib.GetKeepState()
  local args = {449, 442, 647, 1202, "D6F7FF", "-57|-18|2C67C0,-56|21|15447D,55|5|2157AB,92|20|1B4C85,104|-26|183251,37|11|C1E1EC", 0, 0.9}
  if isKeep then
    LuaAuxLib.LuaAuxLib.KeepReleaseScreenSnapshot(0)
  end

  local function doTap()
    local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
    if x > 0 and y > 0 then
      LuaAuxLib.TracePrint("找到经营按钮，点击")
      LuaAuxLib.Tap(x, y)
      LuaAuxLib.Sleep(200)
      LuaAuxLib.TracePrint("延时后递归调用")
      doTap()
    end
  end

  doTap()
  LuaAuxLib.Sleep(200)
  if isKeep then
    LuaAuxLib.KeepReleaseScreenSnapshot(1)
  end
end

-- 点击关闭按钮
jingying.tapClose = function()
  LuaAuxLib.Tap(677, 93)
  return true
end

function QMPlugin.RegisterModule()
  LuaAuxLib.Modules = LuaAuxLib.Modules or {}
  LuaAuxLib.Modules.Jp_Jingying = jingying
end
